const path = require('path')
const webpack = require('webpack')
const htmlWebpackPlugin = require('html-webpack-plugin')
const uglifyJs = require('uglifyjs-webpack-plugin')
module.exports={
    entry:path.join(__dirname,'./src/main.js'),
    output: {
        path: path.join(__dirname,'./dist'),
        filename: "bundle.js",
        // publicPath:"dist/"
    },
    module: {
        rules: [
            { test: /\.css$/, use: ['style-loader','css-loader'] },
            {
                test: /\.(png|jpg|gif)$/,
                use: [
                    {
                        loader: 'url-loader',
                        options: {
                            limit: 8192,
                            // 当文件大于8k时文件命名
                            name:'img/[name].[hash:8].[ext]'
                        }
                    }
                ]
            },
            { test: /\.vue$/, use: ['vue-loader']}
        ]
    },
    resolve: {
        alias: {
            'vue$': 'vue/dist/vue.esm.js' // 用 webpack 1 时需用 'vue/dist/vue.common.js'
        }
    },
    plugins:[
        new webpack.BannerPlugin('最终版权归111所有'),
        new htmlWebpackPlugin({
            template:'index.html'
        }),
        new uglifyJs()
    ],
    devServer:{
        contentBase:'./dist',
        inline:true
    }
}
